﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Cesave.Infrastructure.CrossCutting.Logging;
using Cesave.Infrastructure.CrossCutting.IoC;
using Cesave.DistributedServices.Core.ErrorHandlers;
using System.ServiceModel;
using Cesave.Domain.PermisosModule.Contracts.AreaSecciones;

namespace Cesave.DistributedServices.PermisosModule
{
	public partial class PermisosModuleService
	{
		#region IPermisosModuleService Members
		
		/// <summary>
		/// 
		/// </summary>
		/// <param name="areaSeccion"></param>
		public void AddAreaSeccion(Domain.PermisosModule.Entities.AreaSeccion areaSeccion)
		{
			try
			{
				IAreaSeccionService areaSeccionService = IoCFactory.Resolve<IAreaSeccionService>();
				areaSeccionService.AddAreaSeccion(areaSeccion);
			}
			catch (Exception ex)
			{
				ITraceManager traceManager = IoCFactory.Resolve<ITraceManager>();
				traceManager.TraceError(ex.Message);

				ServiceError detail = ServiceError.Factory(ex.Message);
				throw new FaultException<ServiceError>(detail);
			}
		}

		/// <summary>
		/// 
		/// </summary>
		/// <param name="areaSeccion"></param>
		public void ChangeAreaSeccion(Domain.PermisosModule.Entities.AreaSeccion areaSeccion)
		{
			try
			{
				IAreaSeccionService areaSeccionService = IoCFactory.Resolve<IAreaSeccionService>();
				areaSeccionService.ChangeAreaSeccion(areaSeccion);
			}
			catch (Exception ex)
			{
				ITraceManager traceManager = IoCFactory.Resolve<ITraceManager>();
				traceManager.TraceError(ex.Message);

				ServiceError detail = ServiceError.Factory(ex.Message);
				throw new FaultException<ServiceError>(detail);
			}
		}

		/// <summary>
		/// 
		/// </summary>
		/// <param name="juntaGuid"></param>
		/// <param name="areaGuid"></param>
		/// <returns></returns>
		public List<Domain.PermisosModule.Entities.AreaSeccion> FindAreaSeccionesByJuntaAndArea(Guid juntaGuid, Guid areaGuid)
		{
			try
			{
				IAreaSeccionService areaSeccionService = IoCFactory.Resolve<IAreaSeccionService>();
				return areaSeccionService.FindAreaSeccionesByJuntaAndArea(juntaGuid, areaGuid);
			}
			catch (Exception ex)
			{
				ITraceManager traceManager = IoCFactory.Resolve<ITraceManager>();
				traceManager.TraceError(ex.Message);

				ServiceError detail = ServiceError.Factory(ex.Message);
				throw new FaultException<ServiceError>(detail);
			}
		}

		/// <summary>
		/// 
		/// </summary>
		/// <param name="juntaGuid"></param>
		/// <param name="areaGuid"></param>
		/// <returns></returns>
		public List<Domain.PermisosModule.Entities.AreaSeccion> FindAreaSeccionesForExpedicion(Guid juntaGuid, Guid areaGuid)
		{
			try
			{
				IAreaSeccionService areaSeccionService = IoCFactory.Resolve<IAreaSeccionService>();
				return areaSeccionService.FindAreaSeccionesForExpedicion(juntaGuid, areaGuid);
			}
			catch (Exception ex)
			{
				ITraceManager traceManager = IoCFactory.Resolve<ITraceManager>();
				traceManager.TraceError(ex.Message);

				ServiceError detail = ServiceError.Factory(ex.Message);
				throw new FaultException<ServiceError>(detail);
			}
		}

		#endregion
	}
}
